﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using ProjScan.RecordManager.AssetData;
using ProjScan.Tools;
using UnityEditor;
using UnityEngine;

namespace ProjScan.RecordManager
{
	// Token: 0x02000275 RID: 629
	internal class AudioRecordManager : RecordManagerBase<AudioClipAssetData>
	{
		// Token: 0x060010CA RID: 4298 RVA: 0x0004D970 File Offset: 0x0004BB70
		public override void PrepareAssets()
		{
			this.datas = new List<AudioClipAssetData>();
			string[] array = new string[]
			{
				"aif",
				"wav",
				"ogg",
				"mp3"
			};
			int num = AssetPathManager.Instance.artPathList.Length;
			for (int i = 0; i < num; i++)
			{
				bool isEditor = Singleton<ScanInfo>.Instance.isEditor;
				if (isEditor)
				{
					EditorUtility.DisplayProgressBar("Proj Scan [" + this.TableTag + "]", string.Concat(new string[]
					{
						"Preparing ",
						this.TableTag,
						"(",
						this.datas.Count.ToString(),
						")..."
					}), (float)i * 1f / (float)num);
				}
				string text = AssetPathManager.Instance.artPathList[i];
				string text2 = Path.GetExtension(text).ToLower().Replace(".", "");
				bool flag = Enumerable.Contains<string>(array, text2);
				if (flag)
				{
					this.ActiveAllRecord();
					bool flag2 = this.CheckAssetPathRules(text);
					if (flag2)
					{
						AudioImporter audioImporter = AssetImporter.GetAtPath(text) as AudioImporter;
						bool flag3 = audioImporter != null;
						if (flag3)
						{
							AudioClip audioClip = AssetDatabase.LoadAssetAtPath(text, typeof(AudioClip)) as AudioClip;
							bool flag4 = audioClip != null;
							if (flag4)
							{
								AudioClipAssetData audioClipAssetData = new AudioClipAssetData(AssetPathManager.Instance.GetID(Path.GetDirectoryName(text)), text, audioClip, audioImporter);
								audioClipAssetData.id = this.datas.Count;
								this.ValidateAsset(audioClipAssetData);
								audioClipAssetData.Reset();
								this.datas.Add(audioClipAssetData);
								bool flag5 = this.datas.Count % 100 == 0;
								if (flag5)
								{
									ToolsHelper.GC();
								}
							}
						}
					}
				}
			}
		}

		// Token: 0x17000374 RID: 884
		// (get) Token: 0x060010CB RID: 4299 RVA: 0x0004DB5C File Offset: 0x0004BD5C
		public override string TableTag
		{
			get
			{
				return "audioclip";
			}
		}
	}
}
